package cn.movie.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author yellow
 * 此类用来创建单例对象 加载properties文件
 */
public class ConfigManager {
    private static ConfigManager config;
    private static Properties properties;
    private ConfigManager(){
        InputStream is = ConfigManager.class.getClassLoader().getResourceAsStream("database.properties");
        properties = new Properties();
        try{
            properties.load(is);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    /**创建一个获取构造方法的方法*/
    public static ConfigManager getConfig(){
        if(config==null){
            config = new ConfigManager();
        }
        return config;
    }
    /**通过键获得值*/
    public  String getVal(String key){
        return properties.getProperty(key);
    }
}
